//
//  saomiaoVC.swift
//  01-读取二维码
//
//  Created by xmg on 16/5/21.
//  Copyright © 2016年 xiao_kl. All rights reserved.
//

import UIKit
import AVFoundation

class saomiaoVC: UIViewController {

    @IBOutlet weak var containImageView: NSLayoutConstraint!
    @IBOutlet weak var contentView: UIView!
    
    //3.创建一个会话,主要连接输入和输出
    let session = AVCaptureSession()
    
    //引用当前的视频预览图层
    var layer: AVCaptureVideoPreviewLayer?
    
    
    //一定要在显示之后调用
    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        self.chuangContain()
    }
    
    func chuangContain(){
        self.containImageView.constant = self.contentView.frame.size.width
        self.view.layoutIfNeeded()
        
        self.containImageView.constant = -self.contentView.frame.size.width
        
        UIView.animateWithDuration(2) { () -> Void in
            //设置重复次数
            UIView.setAnimationRepeatCount(MAXFLOAT)
            self.view.layoutIfNeeded()
        }
    }
    
    
    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        
        QRCoedTool.shareQRCoedTool.scan(self.view, result: { (resultStrs) -> () in
            print(resultStrs)
            }, isAddInterest: true, interestFrame: self.contentView.frame)

    }
    
    
    
    
}


